//package com.coffeeloversupportlibrary.coffeelover.domain.article.cotegory;
//
//import android.os.Bundle;
//import android.util.Log;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//
//import androidx.annotation.NonNull;
//import androidx.annotation.Nullable;
//import androidx.databinding.DataBindingUtil;
//import androidx.fragment.app.Fragment;
//import androidx.recyclerview.widget.LinearLayoutManager;
//import androidx.recyclerview.widget.StaggeredGridLayoutManager;
//import androidx.viewpager.widget.ViewPager;
//
//import com.coffeeloversupportlibrary.R;
//import com.coffeeloversupportlibrary.coffeelover.domain.article.entity.Article;
//import com.coffeeloversupportlibrary.coffeelover.uicompont.conflict.NestedScrollingParent2LayoutImpl3;
//import com.coffeeloversupportlibrary.databinding.CategoryItemFragmnetBinding;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * @author puyv
// * @createTime 2021/11/12 8:35
// * @projectName CoffeeLoverSupportLibrary
// * @className CategoryFragment.java
// * @description TODO
// *
// */
//// TODO: 2021/11/22   添加 该类Fragment 的ViewModel 数据和主模块相分离  重构该Fragment
//
//public class CategoryFragment extends Fragment {
//
//
//    private CategoryItemFragmnetBinding categoryItemFragmnetBinding;
//    private NestedScrollingParent2LayoutImpl3 mNestedScrollingParent2Layout;
//    private int mFragmentIndex;
//
//
//    @Nullable
//    @Override
//    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//        categoryItemFragmnetBinding= DataBindingUtil.inflate(inflater, R.layout.category_item_fragmnet,container,false);
//        initView();
//        return categoryItemFragmnetBinding.getRoot();
//    }
//    @Override
//    public void onResume() {
//        super.onResume();
//        Log.e("TAG","super.onResume();"+"true"+mFragmentIndex);
//        if (isCurrentDisplayedFragment()) {
//            if (mNestedScrollingParent2Layout != null) {
//                mNestedScrollingParent2Layout.setChildRecyclerView(categoryItemFragmnetBinding.categoryView);
//            }
//        }
//    }
//    /**
//     * @date 2021/11/11 15:24
//     * @params [visibleToUser]
//     * @return void
//     * @description TODO
//     * 接口回调(因为该方法已过时)
//     */
//    @Override
//    public void setUserVisibleHint(boolean visibleToUser) {
//        super.setUserVisibleHint(visibleToUser);
//
//        if (visibleToUser && isCurrentDisplayedFragment()) {
//            if (mNestedScrollingParent2Layout != null) {
//                mNestedScrollingParent2Layout.setChildRecyclerView(categoryItemFragmnetBinding.categoryView);
//            }
//        }
//    }
//
//
//
//
//
//
//    @Override
//    public void onDestroyView() {
//        super.onDestroyView();
//        categoryItemFragmnetBinding.unbind();
//    }
//
//    private void initView(){
//        categoryItemFragmnetBinding.categoryView.setLayoutManager(new LinearLayoutManager(getContext()));
//        categoryItemFragmnetBinding.categoryView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
//        categoryItemFragmnetBinding.categoryView.setAdapter(null);
//    }
////    private CategoryListAdapter create(){
////        List<Article> lists=new ArrayList<>();
////        Article article1=new Article("coffeeLover",R.drawable.coffee,"文章ID1");
////        Article article2=new Article("coffeeLover",R.drawable.coffee2,"文章ID2");
////        Article article3=new Article("coffeeLover",R.drawable.coffee3,"文章ID3");
////        Article article4=new Article("coffeeLover",R.drawable.cooffee4,"文章ID4");
////        lists.add(article1);
////        lists.add(article2);
////        lists.add(article3);
////        lists.add(article4);
////        lists.add(article1);
////        lists.add(article2);
////        lists.add(article3);
////        lists.add(article4);
////        lists.add(article1);
////        lists.add(article2);
////        lists.add(article3);
////        lists.add(article4);
////        lists.add(article1);
////        lists.add(article2);
////        lists.add(article3);
////        lists.add(article4);
////        lists.add(article1);
////        lists.add(article2);
////        lists.add(article3);
////        return new CategoryListAdapter(lists);
////    }
//
//
//
//
//
//    public void setNestedParentLayout(NestedScrollingParent2LayoutImpl3 nestedScrollingParent2Layout) {
//        mNestedScrollingParent2Layout = nestedScrollingParent2Layout;
//    }
//
//    public void setIndex(int i) {
//        mFragmentIndex = i;
//    }
//
//    //当前Fragment 是否在设备上展示的判定
//    private boolean isCurrentDisplayedFragment() {
//        if (getView() == null || !(getView().getParent() instanceof View)) {
//            return false;
//        }
//        View parent = (View) getView().getParent();
//        if (parent instanceof ViewPager) {
//            ViewPager viewPager = (ViewPager) parent;
//            int currentItem = viewPager.getCurrentItem();
//            return currentItem == mFragmentIndex;
//        }
//        return false;
//    }
//}
